package com.tbit.main.controller;

import com.tbit.common.entity.pojo.vo.OutAgeVO;
import com.tbit.common.entity.view.Result;
import com.tbit.manager.api.OutAgeApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * 一键停运
 * @author <a href="mailto:liu.haoxiang@tbit.com.cn">BUGXiang</a>
 * @version 1.0
 * @since 2025-4-7
 */
@RestController
@RequestMapping("/outAge")
public class OutAgeController {

    @Autowired
    private OutAgeApi outAgeApi;

    /**
     * 查询一键停运信息
     * @param accountId 区域id
     * @return Result<OutAgeVO>
     */
    @GetMapping("/queryOutAge")
    public Result<OutAgeVO> queryOutAge(Integer accountId) {
        if (Objects.isNull(accountId)){
            return Result.error("参数错误");
        }
        return Result.success(outAgeApi.queryOutAge(null, accountId));
    }


    /**
     * 新增或修改一键停运信息
     * @param outAgeVO 一键停运信息
     * @return  Result
     */
    @PostMapping("/addOrUpdate")
    public Result<Object> addOrUpdate(OutAgeVO outAgeVO) {
        if (Objects.isNull(outAgeVO)){
            return Result.error("参数错误");
        }
        return outAgeApi.addOrUpdate(outAgeVO);
    }
}
